﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
        <ol class="breadcrumb">
    <li><a href="/Home.html">Home</a></li>
    <li><a href="/WebApp/WebApi"> Sanelib WebApp</a></li>
    <li class="active">Account Recovery</li>
</ol>
      
            
            <div id="introduction">
                <h1 class="text-left">Account Recovery Controller</h1>
            </div>
            <div>
                <h3>Constructor : AccountRecoveryController </h3>
                <a href="SmartApiController.html" class="btn-link">SmartAPIController</a>
                <table>
                    <tr>
                        <th><strong>Parameters</strong></th>
                    </tr>
                    <tr>
                        <td class="table-bordered">IUserSession,</td>
                        <td class="table-bordered">IMapingEngine,</td>
                        <td class="table-bordered">IAuthenticationService</td>
                    </tr>
                    <tr>
                        <td class="table-bordered">ICryptographer</td>
                        <td class="table-bordered">IViewRepository&lt;MemberView&gt;</td>
                    </tr>
                </table>
                <ol id="method">
                    <li>
                        Post: <a href="/WebApp/Account" class="btn-link">Description of Post</a>
                    </li>
                    <li>
                        Put: Change Password <a href="/WebApp/Account" class="btn-link">Description Of Put Change Password.</a><pre><code> var command = new ChangePassword
            {
                UserId = user.Id,
                OldPassword = form.OldPassword,
                NewPassword = form.NewPassword,
                ConfirmPassword = form.ConfirmPassword,
            };
            return ExecuteCommand(command);</code></pre>
                    </li>
                    <li>
                        Put: ResetPassword, An ResetPasswordForm Object is an argument to the put method, All Fields are validated with the token generated to reset password. the token is then hashed to encrypt. Then the new password is validate for the following Cases
                        <pre>If Token Exits<code>
var encryptToken = _cryptographer.ComputeHash(form.Token);
var member = _memberViewRepository.GetByKey(Property.Of&lt;member&gt;
(x => x.PasswordRetrievalToken), encryptToken);
                            </code></pre>
                        <ol>
                            <li>IsEmpty</li>
                            <li>Least One Lower Case</li>
                            <li>One Upper Case</li>
                            <li>Least One Number</li>
                            <li>Least One Special Characters</li>
                            <li>Matching Confirm Password</li>
                        </ol>
                        <code>EventCoordinator.Raise(new ResetPassword(form.Token, form.NewPassword, form.ConfirmPassword));</code>
                        <code>return Content(WebApiResonseBase.Create("/Account/ResetSuccess", true));</code>
                    </li>
                    <li>
                        Delete: As an arguments it gets RecoverPasswordForm object.
                        <pre><code>public HttpResponseMessage Delete(RecoverPasswordForm form)</code></pre>
                        The Email address or the username is validated and he GetPasswordRecoveryUrl is Executed. An Event Coordinator Raises and Event for the new PasswordRecovery.
                        <pre><code>var url = GetPasswordRecoveryUrl();
 EventCoordinator.Raise(new PasswordRecovered(form.UserNameOrEmailAddress, url));
return Content(WebApiResonseBase.Create("/Account/RecoverSuccess", true));</code></pre>
                        The GetPasswordRecoveryUrl is generated with the configuration provider and the BaseUrl provider and an uri is created to route to an password recovery mechanism. Then  the response of the RecoveryUrl is then returned to the HttpResponse Object.
                        <!--<--><!--pre>--><code>var generalConfig = ConfigProvider.GetGeneralConfig();</code>
                        <code>var uri = generalConfig.ApplicationBaseUrl;</code>
                        <!--</pre>-->
                        <code>return string.Format("{0}{1}", uri, Url.Route("Default", new { controller = "Account", action = "Recover" }));</code>
                    </li>



                </ol>
            </div>
     